<?php
/**
 * Created by PhpStorm.
 * User: reshared
 * Date: 2017/9/28
 * Time: 下午6:17
 */

namespace Index\Controller;


use Index\Model\SmsCodeModel;
use Index\Repository\SMSRepository;

class UserController extends BaseController
{
    /**
     * 预检查,需登录
     */
    public function _initialize()
    {
        $this->checkLogin();
    }

    /**
     * 绑定手机号
     */
    public function blindMobile()
    {
        //检验ajax post
        $this->checkAjaxRequestMethod();
        //检查参数
        $this->hasI('mobile');
        //获取参数
        $mobile = I('mobile');
        //发送验证码
        $r = SMSRepository::instance()->sendMobileCode($mobile, SmsCodeModel::REGISTER);
        //返回结果
        $this->ajaxReturn((bool)$r);
    }
}